package com.zzx.utils;

import java.util.Random;

import org.apache.commons.codec.digest.DigestUtils;

//每次得到一个0-9的8位随机数
public class saltSecurityUtils {
	public static String getRandomString(int length) {
		String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=+*&^%$#@!;/?";
		Random random = new Random();
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < length; i++) {
			int number = random.nextInt(str.length());
			sb.append(str.charAt(number));
		}
		return sb.toString();
	}
	
    public static String md5Encode(String password, String salt){
        // md5混合加密
        StringBuffer mergeBuffer=new StringBuffer(password).append(salt);
        return DigestUtils.md5Hex(mergeBuffer.toString().getBytes()).toString();
    }
	
}
